package com.tao.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tao.dao.MessageMapper;
import com.tao.entity.Message;
import com.tao.entity.User;
import com.tao.service.MessageService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> implements MessageService {
    /**
     * 添加历史消息
     * @param message
     * @return
     */
    @Override
    public Boolean addMessage(Message message) {
        return save(message);
    }

    /**
     * 查询登录用户发送信息的人和给登录用户发送信息的人
     * @param id
     * @return
     */
    @Override
    public List<User> getFriends(Long id) {
        List<User> friendList = this.baseMapper.getFriendList(id);
        return friendList;
    }

    @Override
    public List<Message> getMessages(Long id, Long toId) {
        List<Message> messageList = this.baseMapper.getMessageList(id, toId);
        return messageList;
    }
}
